/**
 业主详情页面
 **/
(function (vc) {
    var _fileUrl = '/callComponent/download/getFile/fileByObjId';
    vc.extends({
        data: {
            systemUserDetailInfo: {
                userId: '',
                userName: '',
                idCard: '',
                tel: '',
                sex: '',
                address: '',
                url: '',
                relCd: '',
                _currentTab: 'aUserDetailAttr',
                needBack: false
            }
        },
        _initMethod: function () {
            $that.systemUserDetailInfo.userId = vc.getParam('userId');
            if (!vc.notNull($that.systemUserDetailInfo.userId)) {
                return;
            }
            $that._loadSystemUser();
            $that.changeTab($that.systemUserDetailInfo._currentTab);
        },
        _initEvent: function () {
            vc.on('systemUserDetail', 'listStaffData', function (_info) {
                $that._loadSystemUser();
                $that.changeTab($that.systemUserDetailInfo._currentTab);
            });
        },
        methods: {
            _loadSystemUser: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        systemUserId: $that.systemUserDetailInfo.userId
                    }
                };
                //发送get请求
                vc.http.apiGet('/user.listSystemUsers',
                    param,
                    function (json) {
                        let _staffInfo = JSON.parse(json);
                        // 员工列表 和 岗位列表匹配
                        vc.copyObject(_staffInfo.data[0], $that.systemUserDetailInfo);
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.systemUserDetailInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    userId: $that.systemUserDetailInfo.userId,
                    userName: $that.systemUserDetailInfo.userName,
                    tel: $that.systemUserDetailInfo.tel,
                })
            },
        }
    });
})(window.vc);